home *** CD-ROM | disk | FTP | other *** search
Wrap
(*************************************************** Ant Movie Catalog importation script www.antp.be/software/moviecatalog/ [Infos] Authors=Epsilon, Antoine Potten Title=Cineguide (Cinebel) Description=Cineguide (Cinebel) - Dutch (BE) import Site=http://www.cineguide.be Language=NL Version= Requires=3.5.0 Comments= License=This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. | GetInfo=1 [Options] SummaryToComments=0|0|0=Puts summary in the description field|1=Puts summary in the comments field ***************************************************) program CINEGUIDE_NL; var MovieName: string; function FindLine(Pattern: string; List: TStringList; StartAt: Integer): Integer; var i: Integer; begin result := -1; if StartAt < 0 then StartAt := 0; for i := StartAt to List.Count-1 do if Pos(Pattern, List.GetString(i)) <> 0 then begin result := i; Break; end; end; procedure AnalyzePage(Address: string); var PageText: string; Block: string; ResultBlock: Integer; BeginPos, EndPos: Integer; ValueTitle, ValueAddress: string; begin PageText := GetPage(Address); if pos('<a href=/fr/film.asp', PageText) > 0 then begin SetField(fieldURL, Address); AnalyzeMoviePage(PageText) end else begin PickTreeClear; ResultBlock := Pos('<td class="cadre" height="16">', PageText); while ResultBlock > 0 do begin Delete(PageText, 1, ResultBlock + 35); EndPos := Pos('</td>', PageText); PickTreeAdd(StringReplace(Copy(PageText, 1, EndPos - 1), #13#10 + ' ', ''), ''); BeginPos := EndPos; EndPos := Pos('<td height="10"> </td>', PageText); Block := Copy(PageText, BeginPos, EndPos - BeginPos); Delete(PageText, 1, EndPos); BeginPos := Pos('<a href="/nl/film.asp', Block); while BeginPos > 0 do begin Delete(Block, 1, BeginPos - 1); EndPos := Pos('</a>', Block); ValueTitle := Copy(Block, 1, EndPos - 1); HTMLRemoveTags(ValueTitle); BeginPos := Pos('"', Block); EndPos := Pos('" class', Block); ValueAddress := 'http://www.cinebel.be' + Copy(Block, BeginPos + 1, EndPos - BeginPos - 1); PickTreeAdd(ValueTitle, ValueAddress); EndPos := Pos('</td>', Block); Delete(Block, 1, EndPos); BeginPos := Pos('<a href="/nl/film.asp', Block); end; ResultBlock := Pos('<td class="cadre" height="16">', PageText); end; if PickTreeExec(Address) then AnalyzePage(Address); end; end; procedure AnalyzeMoviePage(PageText: string); var Line, Value: string; IntValue: Integer; BeginPos, EndPos: Integer; begin BeginPos := Pos('<table border="0" width="95%" cellpadding="0" cellspacing="0">', PageText); Delete(PageText, 1, BeginPos); // Original Title BeginPos := Pos('<b class="cadre">', PageText); Delete(PageText, 1, BeginPos + 16); EndPos := Pos ('</b>', PageText); Value := Copy(PageText, 1, EndPos - 1); SetField(fieldOriginalTitle, Value); // Country & Year BeginPos := Pos(' - ', PageText) + 3; EndPos := Pos('</td>', PageText); Line := Copy(PageText, BeginPos, EndPos - BeginPos); EndPos := Pos(' - ', Line); SetField(fieldCountry, Copy(Line, 1, EndPos - 1)); Delete(Line, 1, EndPos + 2); EndPos := Pos(#13#10, Line); SetField(fieldYear, Copy(Line, 1, EndPos - 1)); // Description BeginPos := Pos('<hr noshade width="100%" size="1" color="#000000">', PageText); Delete(PageText, 1, BeginPos); EndPos := Pos('<hr noshade width="100%" size="1" color="#000000">', PageText); Line := Copy(PageText, 1, EndPos - 1); Delete(PageText, 1, EndPos); BeginPos := Pos('>', Line); Delete(Line, 1, BeginPos); Line := StringReplace(Trim(StringReplace(Line, #13#10, '')), '<br>', #13#10); if GetOption('SummaryToComments') = 1 then SetField(fieldComments, Line) else SetField(fieldDescription, Line); // Director BeginPos := Pos('<b>Regisseur', PageText); Delete(PageText, 1, BeginPos); BeginPos := Pos('</b> ', PageText) + 5; EndPos := Pos('</td>', PageText); Value := Copy(PageText, BeginPos, EndPos - BeginPos); HTMLRemoveTags(Value); SetField(fieldDirector, Value); // Actors BeginPos := Pos('<b>Acteurs', PageText); Delete(PageText, 1, BeginPos); BeginPos := Pos(' </b>', PageText) + 5; EndPos := Pos('</td>', PageText); Value := Copy(PageText, BeginPos, EndPos - BeginPos); Value := StringReplace(Value, ' ', ''); Value := StringReplace(Value, #13#10, ''); HTMLRemoveTags(Value); SetField(fieldActors, Trim(Value)); // Category BeginPos := Pos('<b>Genre', PageText); Delete(PageText, 1, BeginPos); BeginPos := Pos('</b> ', PageText) + 5; EndPos := Pos('</td>', PageText); Value := Copy(PageText, BeginPos, EndPos - BeginPos); EndPos := Pos(#13#10, Value); SetField(fieldCategory, Copy(Value, 1, EndPos - 1)); // Length BeginPos := Pos('<b>Duur', PageText); Delete(PageText, 1, BeginPos); BeginPos := Pos(' </b>', PageText) + 5; EndPos := Pos(' </td>', PageText); Value := Copy(PageText, BeginPos, EndPos - BeginPos); EndPos := Pos('.', Value); IntValue := StrToInt(Copy(Value, 1, EndPos - 1), 0) * 60; IntValue := IntValue + StrToInt(Copy(Value, EndPos + 1, Length(Value)), 0); SetField(fieldLength, IntToStr(IntValue)); //DisplayResults; end; begin if CheckVersion(3,5,0) then begin MovieName := GetField(fieldOriginalTitle); if MovieName = '' then MovieName := GetField(fieldTranslatedTitle); if Input('Cineguide (Cinebel) Import', 'Enter the title (or the URL) of the movie:', MovieName) then begin if Pos('cinebel.be', MovieName) > 0 then AnalyzePage(MovieName) else AnalyzePage('http://www.cinebel.be/nl/srch.asp?mot='+UrlEncode(MovieName)); end; end else ShowMessage('This script requires a newer version of Ant Movie Catalog (at least the version 3.5.0)'); end.